package com.concurrent.action.chapter7;

import java.nio.Buffer;
import java.util.concurrent.FutureTask;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description:
 * @Author: yangzhiwei
 * @Date: 2021/7/5 15:44
 */
public class _7_1_4 {
    public static void main(String[] args) {
        Lock lock = new ReentrantLock();
        lock.tryLock();
        FutureTask futureTask;
        Buffer buffer;
        Thread t =  new MyThread();
      t.start();
        System.out.println(t.getUncaughtExceptionHandler());
    }
}


class MyThread   extends Thread {

    @Override
    public void run() {
       testRuntimeException();
    }

    @Override
    public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
        super.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                System.out.println("from Here");
                e.printStackTrace();
            }
        });
    }

    public void testRuntimeException() {
        throw new RuntimeException();
    }
}